#include <bits/stdc++.h>
#define N 500005
using namespace std;
typedef long long ll;

int n, m, B;
ll ans;
int dx[4]={ 1, 0, -1, 0 };
int dy[4]={ 0, 1, 0, -1 };

struct Pnt { int x, y; } p[N];
queue <Pnt> q;

map <int, int> cnt[N];
map <int, bool> vst[N];

int main ()
{
    freopen("grid.in", "r", stdin);
    freopen("grid.out", "w", stdout);

    scanf("%d %d %d", &n, &m, &B);
    for (int i=1; i<=B; i++) {
        scanf("%d %d", &p[i].x, &p[i].y);
        if (!vst[p[i].x][p[i].y]) {
            vst[p[i].x][p[i].y]=1; ans++;
            q.push((Pnt){ p[i].x, p[i].y });
        }
    }

    while (!q.empty()) {
        int x=q.front().x, y=q.front().y; q.pop();
        for (int i=0; i<4; i++) {
            int nx=x+dx[i], ny=y+dy[i];
            if (nx<1 || ny<1 || nx>n || ny>m || vst[nx][ny]) { continue; }
            cnt[nx][ny]++;
            if (cnt[nx][ny]>=2) {
                vst[nx][ny]=1; ans++;
                q.push((Pnt){ nx, ny });
            }
        }
    }

    printf("%lld\n", ans);

    return 0;
}